list=['张三,男,18','李四,男,19','王五,男,20']

with open('data.txt','w',encoding='UTF-8')as f:
    for i in list:
        f.write(i)
        f.write('\n')